from django.http import HttpResponse,HttpResponseRedirect
from django.shortcuts import render
from django.urls import reverse

from .models import Book,Author

# Create your views here.
def all_book(request):
    books=Book.objects.filter(isActive=True)
    return render(request, 'book/all_book.html',locals())


def del_book(request):
    book_id=request.GET.get('id')
    b1=Book.objects.get(id=book_id)
    b1.isActive=False
    b1.save()
    url=reverse('allbook')
    return HttpResponseRedirect(url)